import React from 'react';

// ... rest of your code

import { Input, Button } from 'antd';

export const getColumnSearchProps = (dataIndex, handleSearch, handleReset) => ({
  filterDropdown: ({ setSelectedKeys, selectedKeys, confirm, clearFilters }) => (
    <div style={{ padding: 8 }}>
      <Input
        placeholder={`Search ${dataIndex}`}
        value={selectedKeys[0]}
        onChange={(e) => setSelectedKeys(e.target.value ? [e.target.value] : [])}
        onPressEnter={() => handleSearch(selectedKeys, confirm, dataIndex)}
        style={{ marginBottom: 8, display: 'block' }}
      />
      <Button
        type="primary"
        onClick={() => handleSearch(selectedKeys, confirm, dataIndex)}
        icon="search"
        size="small"
        style={{ width: 60, marginRight: 2 }}
      >
        搜索
      </Button>
      <Button onClick={() => handleReset(clearFilters)} size="small" style={{ width: 90 }}>
        重置
      </Button>
    </div>
  ),
  filterIcon: () => <Button type="primary" shape="circle" icon="search" />,
  onFilter: (value, record) =>
    record[dataIndex] ? record[dataIndex].toString().toLowerCase().includes(value.toLowerCase()) : '',
});

export const filterUserRoles = (roles, roleToRemoveIfBothPresent) => {
  const hasBothRoles = roles.includes('business') && roles.includes('designer');

  if (hasBothRoles && roleToRemoveIfBothPresent) {
    return roles.filter(role => role !== roleToRemoveIfBothPresent);
  }

  return roles;
};

